<#assign title='config_files' />
<#assign activeTitle="config_file" />
<#include "/frag.head.ftl">

<ol class="breadcrumb">
  <li><a href="/tree/">root</a></li>
<#assign lj="/" />
<#list paths as p>
    <#assign lj=lj+"/"+p />
  <li><a href="/tree${lj}">${p}</a></li>
</#list>
</ol>

<div class="row">
  <div class="col-xs-12">
    <div id="toolbar"></div>
  </div>
  <div class="col-xs-12">
    <table id="dataGrid"></table>
  </div>
</div>

<#include "/frag.foot.ftl">

<script type="text/javascript">

  $(document).ready(function () {

    $("#dataGrid").bootstrapTable({
      data: ${ls},
      striped: false,
      uniqueId: 'name',
      searchable: true,
      paginationHAlign: 'left',
      paginationDetailHAlign: 'right',
      paginationLoop: false,
      sortable: true,
      searchAlign: 'left',
      pagination: true,
      sidePagination: 'client',
      pageSize: 10,
      showFullscreen: true,
      pageList: [10, 20, 50, 'ALL'],
      search: true,

      columns: [{
        field: 'name',
        title: '名称',
        align: 'left',
        valign: 'middle',
        formatter: function (v, row, index) {
          if (row.file) {
            return '<i class="fa fa-file-code-o"></i><a href="/view/${path}/' + v + '">' + v + '</a>'
          } else {
            return '<i class="fa fa-folder"></i><a href="/tree/${path}/' + v + '">' + v + '</a>'
          }
        }
      }, {
        title: "操作",
        align: 'center',
        valign: 'middle',
        width: 130,
        formatter: function (v, row, index) {
          var actions = [];
          if(row.file) {
            actions.push('<a class="btn btn-default btn-sm" href="/edit/${path}/' + row.name + '">Edit</a>&nbsp;');
          }
          actions.push('<button class="btn btn-warning btn-sm" onclick="deleteFile(\'${path}/' + row.name + '\');">Delete</button>&nbsp;');
          return actions.join('');
        }
      }
      ]
    });
  });

</script>